package com.hf.session;

import java.sql.Blob;
import java.util.ArrayList;
import java.util.List;

import tool.TimeTool;

import com.base.bean.*;
import com.base.dao.*;
import com.base.service.MsessionService;

/**
 * 消息会话管理
 * @author chz
 *
 */

@Deprecated
public abstract class AbstractSession {
	@SuppressWarnings("deprecation")
	private MsessionService mserv;
	
	public AbstractSession(){
		this.mserv = MsessionService.getInstance();
	}
	
	/**
	 * 获取一个初始化后的SerializeBean
	 * @return
	 */
	public abstract SerializeBean getNewSerializeBean();
	
	/**
	 * 操作业务对象并返回对象状态 
	 * @param sessionId
	 * @param opper
	 * @param oppType
	 * @param msg
	 * @return 返回业务对象的当前状态 or session对象的状态 并将此状态写入MSessionObj:state
	 */
	public abstract int oppToObjState(Integer sessionId,int opper,int oppType,String msg);

	
	
	//创建会话
	public Integer createSession(Integer creator){
		MsessionBase session = new MsessionBase();
		session.setCreator(creator);
		
		Integer sid = this.mserv.createMsession(session);
		if(!creator.equals(0)){		//若非系统创建 则添加创建人
			this.mserv.addReceiver(sid, creator);
		}
	}
	
	

	/**关闭会话
	 * state=2 is close
	 * @param sid
	 * return >1:success
	 */
	public int close(int sid){
		return this.mserv.changeState(sid, 2);
	}
	

	




	

	
	
	
}
